<feed xmlns='http://www.w3.org/2005/Atom'>
<title>Low-Battery-Yup/Low Battery Yup d, branch master</title>
<subtitle>Dismiss Mac OS X's low battery warning dialog with the keyboard</subtitle>
<link rel='alternate' type='text/html' href='https://git.teddywing.com/Low-Battery-Yup/'/>
<entry>
<title>Add copyright and license text to all source files</title>
<updated>2016-12-03T06:06:52+00:00</updated>
<author>
<name>Teddy Wing</name>
</author>
<published>2016-12-03T06:06:52+00:00</published>
<link rel='alternate' type='text/html' href='https://git.teddywing.com/Low-Battery-Yup/commit/?id=ce4e6e5cae1b1144d6bdd95c6ed2ce663ec31e1c'/>
<id>ce4e6e5cae1b1144d6bdd95c6ed2ce663ec31e1c</id>
<content type='text'>
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
</pre>
</div>
</content>
</entry>
<entry>
<title>Clean up code from 9d91a7c908dc2261f2c3335875323c7088938204</title>
<updated>2016-12-03T05:32:01+00:00</updated>
<author>
<name>Teddy Wing</name>
</author>
<published>2016-12-03T05:32:01+00:00</published>
<link rel='alternate' type='text/html' href='https://git.teddywing.com/Low-Battery-Yup/commit/?id=7ffa846dff745feaccdc34d0d4caf72850bcd55d'/>
<id>7ffa846dff745feaccdc34d0d4caf72850bcd55d</id>
<content type='text'>
* Remove the old point assignments
* Remove the comments describing the pixel offsets from the bottom-left
  of the low battery alert window
* Remove the NSLog for inspecting the frame rect values
* Remove the `width` variable which is no longer used
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
* Remove the old point assignments
* Remove the comments describing the pixel offsets from the bottom-left
  of the low battery alert window
* Remove the NSLog for inspecting the frame rect values
* Remove the `width` variable which is no longer used
</pre>
</div>
</content>
</entry>
<entry>
<title>Click the right spot on all screen sizes</title>
<updated>2016-12-03T05:22:17+00:00</updated>
<author>
<name>Teddy Wing</name>
</author>
<published>2016-12-03T05:22:17+00:00</published>
<link rel='alternate' type='text/html' href='https://git.teddywing.com/Low-Battery-Yup/commit/?id=9d91a7c908dc2261f2c3335875323c7088938204'/>
<id>9d91a7c908dc2261f2c3335875323c7088938204</id>
<content type='text'>
Previously, the point set to be clicked for the low battery alert was
only valid on a 13" 1440x900 screen. This change allows the click
functionality to work on any screen size.

I discovered in 954071bcc651ed5876d8ac0c3e8c253d4470c416 that I couldn't
use a percentage to get the height of the "OK" button.

But, the low battery alert uses `NSWindow`'s `-center` method, so I
thought up a hack to make a fake window, center it, and get the window's
frame dimensions. The fake window I create has the same (close enough)
dimensions as the low battery alert (measured from a screenshot).

I then use those dimensions to figure out where to click so that I'm
clicking in the right place on the "OK" button.

We also add a check to reinitialise the dimensions and reset the current
window if the main window has changed from what we thought it was. This
should allow the app to still work if you launch it from one display and
later plug in another as your main display where the low battery warning
will now appear.

We need to subtract the frame's Y coordinate from the screen height
because the frame origin uses standard bottom-left origin coordinates,
while `CGDisplayMoveCursorToPoint` uses top-left origin coordinates.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Previously, the point set to be clicked for the low battery alert was
only valid on a 13" 1440x900 screen. This change allows the click
functionality to work on any screen size.

I discovered in 954071bcc651ed5876d8ac0c3e8c253d4470c416 that I couldn't
use a percentage to get the height of the "OK" button.

But, the low battery alert uses `NSWindow`'s `-center` method, so I
thought up a hack to make a fake window, center it, and get the window's
frame dimensions. The fake window I create has the same (close enough)
dimensions as the low battery alert (measured from a screenshot).

I then use those dimensions to figure out where to click so that I'm
clicking in the right place on the "OK" button.

We also add a check to reinitialise the dimensions and reset the current
window if the main window has changed from what we thought it was. This
should allow the app to still work if you launch it from one display and
later plug in another as your main display where the low battery warning
will now appear.

We need to subtract the frame's Y coordinate from the screen height
because the frame origin uses standard bottom-left origin coordinates,
while `CGDisplayMoveCursorToPoint` uses top-left origin coordinates.
</pre>
</div>
</content>
</entry>
<entry>
<title>Mouse.m: Some calculations on window center</title>
<updated>2016-12-02T23:53:55+00:00</updated>
<author>
<name>Teddy Wing</name>
</author>
<published>2016-12-02T23:53:55+00:00</published>
<link rel='alternate' type='text/html' href='https://git.teddywing.com/Low-Battery-Yup/commit/?id=954071bcc651ed5876d8ac0c3e8c253d4470c416'/>
<id>954071bcc651ed5876d8ac0c3e8c253d4470c416</id>
<content type='text'>
Wanted to get a percentage that I could apply to the height to get to
the right pixel position on the screen, but it doesn't seem like it's
going to be that simple. The percentages are off for a big screen and a
small screen, so I can't rely on a single percentage value.

After some research, my current idea is to make a fake window, call
NSWindow -center on it, and get the coordinates of that window to figure
out where the mouse should be positioned.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Wanted to get a percentage that I could apply to the height to get to
the right pixel position on the screen, but it doesn't seem like it's
going to be that simple. The percentages are off for a big screen and a
small screen, so I can't rely on a single percentage value.

After some research, my current idea is to make a fake window, call
NSWindow -center on it, and get the coordinates of that window to figure
out where the mouse should be positioned.
</pre>
</div>
</content>
</entry>
<entry>
<title>Make click work from hotkey in NSUserDefaults</title>
<updated>2016-12-01T18:36:32+00:00</updated>
<author>
<name>Teddy Wing</name>
</author>
<published>2016-12-01T18:36:32+00:00</published>
<link rel='alternate' type='text/html' href='https://git.teddywing.com/Low-Battery-Yup/commit/?id=22e657a042d653e5abcdb876d843bb80343e9053'/>
<id>22e657a042d653e5abcdb876d843bb80343e9053</id>
<content type='text'>
Get the shortcut saved from the windows application in our daemon and if
there is one, use that as the hotkey to activate the mouse click.

Yay! This is coming together!
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Get the shortcut saved from the windows application in our daemon and if
there is one, use that as the hotkey to activate the mouse click.

Yay! This is coming together!
</pre>
</div>
</content>
</entry>
<entry>
<title>AppDelegate: Only allocate one `Mouse` instance in app lifecycle</title>
<updated>2016-11-19T04:14:04+00:00</updated>
<author>
<name>Teddy Wing</name>
</author>
<published>2016-11-19T04:14:04+00:00</published>
<link rel='alternate' type='text/html' href='https://git.teddywing.com/Low-Battery-Yup/commit/?id=4a5d68ef73f44536feb38bb5033fe190b9b7a813'/>
<id>4a5d68ef73f44536feb38bb5033fe190b9b7a813</id>
<content type='text'>
Don't keep allocating and releasing `Mouse` objects when the hotkey is
pressed. Instead, allocate a single instance to use for the entire run
time of the application.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Don't keep allocating and releasing `Mouse` objects when the hotkey is
pressed. Instead, allocate a single instance to use for the entire run
time of the application.
</pre>
</div>
</content>
</entry>
<entry>
<title>Use hard-coded hotkey to invoke battery dialog dismisser</title>
<updated>2016-11-19T03:54:19+00:00</updated>
<author>
<name>Teddy Wing</name>
</author>
<published>2016-11-19T03:54:19+00:00</published>
<link rel='alternate' type='text/html' href='https://git.teddywing.com/Low-Battery-Yup/commit/?id=678f8ca1a961eb9125aa82b7d2277fda4db7f146'/>
<id>678f8ca1a961eb9125aa82b7d2277fda4db7f146</id>
<content type='text'>
* Add DDHotKey library to the project. Just copy the files in from the
  latest HEAD@e0481f648e0bc7e55d183622b00510b6721152d8.
* Only add DDHotKeyCenter.{h,m} &amp; DDHotKeyUtilities.{h,m} to the "Low
  Battery Yup.d" target as the *TextField file is only useful for a UI
  to choose a hotkey, and we don't have a UI in this target.
* Set the DDHotKey* files to use ARC when compiling since they require
  it. This was done by going to Build Phases -&gt; Compile Sources and
  adding this flag for both files:

      -fobj-arc

  this I figured out thanks to the following SO post:

    http://stackoverflow.com/questions/6448874/disable-automatic-reference-counting-for-some-files/10255815#10255815

* Link Carbon.framework because DDHotKey depends on it to register
  global hotkeys
* Move our mouse moving &amp; clicking code to a new method that gets used
  as the global hotkey action
* Fix a runtime error caused by MainMenu.xib not being available (as a
  result of f0e8b5188e6fb984511eb01849380669e69632a6). To do this, we
  modify `main.m` to bypass the check for MainMenu.xib as described in
  this SO post:

    http://stackoverflow.com/questions/6945872/cocoa-app-without-a-mainmenu-xib/6946016#6946016

* Delete the `window` `IBOutlet` since we no longer have a MainMenu.xib
  and don't have a window in this app.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
* Add DDHotKey library to the project. Just copy the files in from the
  latest HEAD@e0481f648e0bc7e55d183622b00510b6721152d8.
* Only add DDHotKeyCenter.{h,m} &amp; DDHotKeyUtilities.{h,m} to the "Low
  Battery Yup.d" target as the *TextField file is only useful for a UI
  to choose a hotkey, and we don't have a UI in this target.
* Set the DDHotKey* files to use ARC when compiling since they require
  it. This was done by going to Build Phases -&gt; Compile Sources and
  adding this flag for both files:

      -fobj-arc

  this I figured out thanks to the following SO post:

    http://stackoverflow.com/questions/6448874/disable-automatic-reference-counting-for-some-files/10255815#10255815

* Link Carbon.framework because DDHotKey depends on it to register
  global hotkeys
* Move our mouse moving &amp; clicking code to a new method that gets used
  as the global hotkey action
* Fix a runtime error caused by MainMenu.xib not being available (as a
  result of f0e8b5188e6fb984511eb01849380669e69632a6). To do this, we
  modify `main.m` to bypass the check for MainMenu.xib as described in
  this SO post:

    http://stackoverflow.com/questions/6945872/cocoa-app-without-a-mainmenu-xib/6946016#6946016

* Delete the `window` `IBOutlet` since we no longer have a MainMenu.xib
  and don't have a window in this app.
</pre>
</div>
</content>
</entry>
<entry>
<title>AppDelegate.m: Release allocated `Mouse` instance</title>
<updated>2016-11-17T12:17:46+00:00</updated>
<author>
<name>Teddy Wing</name>
</author>
<published>2016-11-17T12:17:46+00:00</published>
<link rel='alternate' type='text/html' href='https://git.teddywing.com/Low-Battery-Yup/commit/?id=7677b59543a8d2edc9a28f77f26ebb02492e2b5c'/>
<id>7677b59543a8d2edc9a28f77f26ebb02492e2b5c</id>
<content type='text'>
Since we alloc-inited the mouse, we need to make sure to release it when
we're done with it. Forgot to do this when I originally wrote this bit.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Since we alloc-inited the mouse, we need to make sure to release it when
we're done with it. Forgot to do this when I originally wrote this bit.
</pre>
</div>
</content>
</entry>
<entry>
<title>Remove MainMenu.xib</title>
<updated>2016-11-16T09:56:51+00:00</updated>
<author>
<name>Teddy Wing</name>
</author>
<published>2016-11-16T09:56:51+00:00</published>
<link rel='alternate' type='text/html' href='https://git.teddywing.com/Low-Battery-Yup/commit/?id=f0e8b5188e6fb984511eb01849380669e69632a6'/>
<id>f0e8b5188e6fb984511eb01849380669e69632a6</id>
<content type='text'>
Since this is a backround app
(3db243f3c84f7ab36747f4badfd4f57a26563821), we don't have a UI and have
no need for any nib files.

We'll make an additional target as a separate application that does
have a UI and will allow customisation of the global hotkey.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Since this is a backround app
(3db243f3c84f7ab36747f4badfd4f57a26563821), we don't have a UI and have
no need for any nib files.

We'll make an additional target as a separate application that does
have a UI and will allow customisation of the global hotkey.
</pre>
</div>
</content>
</entry>
<entry>
<title>Mouse: Change mouse coordinates to Low Battery OK button</title>
<updated>2016-11-16T09:51:45+00:00</updated>
<author>
<name>Teddy Wing</name>
</author>
<published>2016-11-16T09:51:45+00:00</published>
<link rel='alternate' type='text/html' href='https://git.teddywing.com/Low-Battery-Yup/commit/?id=b3e644a6ec9d14554f4268d38b543cc1d8b7197e'/>
<id>b3e644a6ec9d14554f4268d38b543cc1d8b7197e</id>
<content type='text'>
Modify the coordinates such that instead of clicking the center of the
screen, we click the OK button on the low battery warning dialog.

Rename the method according to its new intent.

TODO: This probably doesn't work on other displays that have different
resolutions. We need to check that and figure out a cross-display
solution.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Modify the coordinates such that instead of clicking the center of the
screen, we click the OK button on the low battery warning dialog.

Rename the method according to its new intent.

TODO: This probably doesn't work on other displays that have different
resolutions. We need to check that and figure out a cross-display
solution.
</pre>
</div>
</content>
</entry>
</feed>
